package ch.elektroplan.mueller.passwordSave.business.supporters;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;

public class Password_DB_Generator extends SQLiteOpenHelper {

	private static final int DB_VERSION = 1;
	private static final String DB_NAME = "passwords.db";

	public static final String USERTABLE = "userValues";
	public static final String ID = "_id";
	public static final String NAME = "name";
	public static final String FIRSTNAME = "firstname";
	public static final String USERNAME = "username";
	public static final String IP = "ip";
	public static final String TYPE = "type";
	public static final String PASSWORD = "password";
	public static final String DATATABLE = "datatable";
	public static final String KEY = "raw";

	private static final String PASSWORDSAFE_DB_CREATE = "CREATE TABLE "
			+ USERTABLE + " (" + ID + " INTEGER PRIMARY KEY AUTOINCREMENT,"
			+ NAME + " TEXT," + FIRSTNAME + " TEXT," + IP + " TEXT," + USERNAME
			+ " TEXT,"+PASSWORD + " TEXT);";


	private static final String PASSWORD_DB_DROP = "DROP TABLE IF EXISTS test";

	public Password_DB_Generator(Context context) {
		super(context, DB_NAME, null, DB_VERSION);

	}

	@Override
	public void onCreate(SQLiteDatabase db) {
		db.execSQL(PASSWORDSAFE_DB_CREATE);
		//db.execSQL(DATATABLE_DB_CREATE);
	}

	@Override
	public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

		db.execSQL(PASSWORD_DB_DROP);
		onCreate(db);
	}

	public String[] getAllColumns() {

		return new String[] { ID, NAME, FIRSTNAME,
				USERNAME, IP, PASSWORD };
	}
}
